package assist.domain.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;

import assist.domain.model.StatsQuery;
import assist.domain.model.StatsQuery.RowQuery;

public class Stats extends ArrayList<Stats.Row> 
    implements Serializable
{
    private static final long serialVersionUID = 1L;
    
    private StatsQuery statsQuery;
        
    public static class Row implements Serializable,Comparable<Row>
    {
        private static final long serialVersionUID = 1L;
        private Map<StatsQuery.Column, Double> dataMap = new TreeMap<StatsQuery.Column, Double>();
        private RowQuery rowQuery;

        @Override
        public int compareTo(Row arg0)
        {
            // TODO For sorting the results, 
            return 0;
        }
        public String getFormatted(StatsQuery.Column column)
        {            
            return "Format:" + this.get(column);            		
        }
        public Double get(StatsQuery.Column column)
        {
            // TODO Auto-generated method stub
            return dataMap.get(column);
        }
        public RowQuery getRowQuery()
        {        
            return rowQuery;
        }
        public void set(StatsQuery.Column column, Double data)
        {
            dataMap.put(column, data);
        }
        public void setRowQuery(RowQuery rowQuery)
        {
            this.rowQuery = rowQuery;
        }
        
    }

    public StatsQuery getStatsQuery()
    {
        return this.statsQuery;
    }


    public void setStatsQuery(StatsQuery statsQuery)
    {
        this.statsQuery = statsQuery;
    }


    public boolean isCalculated()
    {        
System.err.println("this.statsQuery" + this.statsQuery);  
if (this.statsQuery == null){return false;}
System.err.println("this.size()" + this.size());
System.err.println("this.statsQuery.getNumRowQueries()" + this.statsQuery.getNumRowQueries());
        return this.statsQuery != null && this.size() == this.statsQuery.getNumRowQueries();
    }




}
